<?php
class Sfs_View_Helper_TaiwanDate
{
    const COUNTRY_BRIEF_NAME = 1;
    const COUNTRY_LONG_NAME = 2;
    const YEAR_MONTH = 3;

    function TaiwanDate($date='',$isWholeName = 0) {
        if ($date=='')
        $date = date("Y-m-d");
        if (!Zend_Date::isDate($date,'YYYY-MM-DD'))
        throw new Exception('Error date formate , just accept YYYY-MM-DD fromate');

        $arr = explode ("-",$date);
        switch ($isWholeName) {
            case self::COUNTRY_BRIEF_NAME:
                return '民國'.($arr[0]-1911).'年'.$arr[1].'月'.$arr[2].'日';
                break;
            case self::COUNTRY_LONG_NAME:
                return '中華民國'.($arr[0]-1911).'年'.$arr[1].'月'.$arr[2].'日';
                break;
            case self::YEAR_MONTH:
                return ($arr[0]-1911).'-'.$arr[1];
                break;
            default:
               return ($arr[0]-1911).'-'.$arr[1].'-'.$arr[2];
        }

    }
}